<?php
/**
 * Created by litong on Date: 2019/2/24 0024 下午 7:41
 * mysqli 面向对象的方式创建数据库
 */
$host="127.0.0.1";
$username="root";
$password="";
$connection = new mysqli($host, $username, $password);
if($connection->connect_error){
  die("连接失败:".$connection->connect_error.PHP_EOL);
}
$sql="create database database1"; //创建数据库的语句
if($connection->query($sql)){
  echo "创建数据库成功",PHP_EOL;
}else{ //$connection->error 数据库创建失败返回的错误信息
  echo "创建数据库失败:".$connection->error,PHP_EOL;
}
$connection->close();
